{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-n-s-top">
    <div class="t-month-title">按年统计</div>
    <div class="t-month-con">
		<form method="POST" action="">
        <div class="t-con-list">
            <div class="formitems inline">  
                <label class="fi-name" style="width:60px;">请选择：</label>  
                <div class="form-controls" style=" margin-left:60px;">  
                    <select class="mini" name="year" id="year1">  
                        <option value="2014" {if $year == 2014}selected{/if}>2014</option>  
                        <option value="2015" {if $year == 2015}selected{/if}>2015</option>  
                        <option value="2016" {if $year == 2016}selected{/if}>2016</option>  
                        <option value="2017" {if $year == 2017}selected{/if}>2017</option>  
                        <option value="2018" {if $year == 2018}selected{/if}>2018</option>  
                        <option value="2019" {if $year == 2019}selected{/if}>2019</option>  
                        <option value="2020" {if $year == 2020}selected{/if}>2020</option> 
                    </select>  
                    <span>年</span>  
                </div>  
            </div>
        </div>
        <div class="t-con-list" style="padding:0 20px;"> 
            <div class="radio-group" style="padding-top:0px;_padding-top:5px;">  
            <label><input type="radio" name="stat_type" id="stat_type1" value="trade_num" {if $stat_type != 'profit'}checked{/if}>交易额</label>  
            <label><input type="radio" name="stat_type" id="stat_type2" value="profit" {if $stat_type == 'profit'}checked{/if}>利润</label>  
        	</div>
        </div>
        <div class="t-con-list">
			<button type="submit" class="btn">筛选</button>
        </div>
		</form>
		<form method="POST" action="">
			<input type="hidden" name="act" value="export_year_data">
			<input type="hidden" name="year" id="hidden_year1" value="{$year}">
			<input type="hidden" name="stat_type" id="hidden_stat_type1" value="{$stat_type}">
            <span class="t-s"><button type="submit" class="btn">生成报表</button></span>
		</form>
    </div>
	<div class="t-month-money">
		<span>
		{if isset($stat_type) && $stat_type == 'profit'}
			总利润：{$year_total_profit}元
			</span>
			<span>峰值利润：{$max_month_num}元
		{else}
			总交易额：{$year_total_volume_of_trade}元
			</span>
			<span>峰值交易额：{$max_month_num}元
		{/if}
		</span>
	</div>
	<div class="t-month-chart" id="year_container"></div>
</div>

<div class="t-n-s-bottom">
    <div class="t-month-title">按月统计</div>
    <div class="t-month-con">
		<form method="POST" action="">
        <div class="t-con-list">
        	<div class="formitems inline">  
                <label class="fi-name" style="width:60px;">请选择：</label>  
                <div class="form-controls" style=" margin-left:60px;">  
                    <select class="mini" name="year" id="year1">  
                        <option value="2014" {if $year == 2014}selected{/if}>2014</option>  
                        <option value="2015" {if $year == 2015}selected{/if}>2015</option>  
                        <option value="2016" {if $year == 2016}selected{/if}>2016</option>  
                        <option value="2017" {if $year == 2017}selected{/if}>2017</option>  
                        <option value="2018" {if $year == 2018}selected{/if}>2018</option>  
                        <option value="2019" {if $year == 2019}selected{/if}>2019</option>  
                        <option value="2020" {if $year == 2020}selected{/if}>2020</option> 
                    </select>  
                    <span>年</span>  
                </div>  
            </div>
         </div> 
         <div class="t-con-list">    
            <div class="formitems inline">  
                <div class="form-controls" style=" margin-left:10px;">  
                    <select class="mini" name="month" id="month">  
                        <option value="1" {if $month == 1}selected{/if}>1</option>  
                        <option value="2" {if $month == 2}selected{/if}>2</option>  
                        <option value="3" {if $month == 3}selected{/if}>3</option>  
                        <option value="4" {if $month == 4}selected{/if}>4</option>  
                        <option value="5" {if $month == 5}selected{/if}>5</option>  
                        <option value="6" {if $month == 6}selected{/if}>6</option>  
                        <option value="7" {if $month == 7}selected{/if}>7</option>  
                        <option value="8" {if $month == 8}selected{/if}>8</option>  
                        <option value="9" {if $month == 9}selected{/if}>9</option>  
                        <option value="10" {if $month == 10}selected{/if}>10</option>  
                        <option value="11" {if $month == 11}selected{/if}>11</option>  
                        <option value="12" {if $month == 12}selected{/if}>12</option>
                    </select>  
                    <span>月</span>  
                </div>  
            </div>  
        </div>
        <div class="t-con-list" style="padding:0 20px;"> 
            <div class="radio-group" style="padding-top:0px;_padding-top:5px;">  
			<label><input type="radio" name="stat_type" id="stat_type3" value="trade_num" {if $stat_type != 'profit'}checked{/if}>交易额</label>  
            <label><input type="radio" name="stat_type" id="stat_type4" value="profit" {if $stat_type == 'profit'}checked{/if}>利润</label>  
        	</div>  
        </div>
        <div class="t-con-list">
			<button type="submit" class="btn">筛选</button>
        </div>
		</form>
		<form method="POST" action="">
			<input type="hidden" name="act" value="export_month_data">
			<input type="hidden" name="year" id="hidden_year2" value="{$year}">
			<input type="hidden" name="month" id="hidden_month2" value="{$month}">
			<input type="hidden" name="stat_type" id="hidden_stat_type2" value="{$stat_type}">
            <span class="t-s"><button type="submit" class="btn">生成报表</button></span>
		</form>
    </div>
	<div class="t-month-money">
		<span>
			{if isset($stat_type) && $stat_type == 'profit'}
			总利润：{$year_total_profit}元
			</span>
			<span>峰值利润：{$max_day_num}元
			{else}
				总交易额：{$year_total_volume_of_trade}元
				</span>
				<span>峰值交易额：{$max_day_num}元
			{/if}
		</span>
	</div>
	<div class="t-month-chart" id="month_container"></div>
</div>
{/block} 

{block name="js"}
<script type="text/javascript" src="/Public/Plugins/Highcharts/highcharts.js?version={$version}"></script>
<script type="text/javascript">
var year = '{$year}';
var selected_month = '{$month}';
var day_num = '{$day_num}';
var stat_type = '{$stat_type}';
var data = '[';
{foreach from=$month_stat_data_list item=data}
	data += {$data} + ',';
{/foreach}
data = data.substr(0, data.length - 1);
data += ']';

var month_data = '[';
{foreach from=$day_stat_data_list item=data}
	month_data += {$data} + ',';
{/foreach}
month_data = month_data.substr(0, month_data.length - 1);
month_data += ']';

//月份
var month = '[';
for (var i = 1; i <= 12; i++)
{
	month += i + ',';
}
month = month.substr(0, month.length - 1);
month += ']';

//日期
var day = '[';
for (var i = 1; i <= day_num; i++)
{
	day += i + ',';
}
day = day.substr(0, day.length - 1);
day += ']';

//显示名称
var title = stat_type == 'profit' ? '订单商品利润统计' : '订单交易额统计';
var yAxis_title = stat_type == 'profit' ? '利润' : '交易额';
{literal}
$(function (){
	$("#year_container").highcharts(
		{"credits":{"text":"@\u542f\u535a\u8f6f\u4ef6","enabled":false,"href":"http:\/\/www.360shop.com.cn","position":{"align":"right","y":-10}},"legend":{"enabled":true,"layout":"vertical","align":"right","verticalAlign":"middle","borderWidth":0},"xAxis":{"categories":eval(month),"title":{"text":"时间"}},"title":{"text":title + "(" + year + "年)"},"yAxis":{"title":{"text":yAxis_title},"allowDecimals":false,"plotLines":[{"value":0,"width":1,"color":"#808080"}],"min":0},"plotOptions":{"line":{"dataLabels":{"enabled":true},"enableMouseTracking":true}},"series":[{"type":"column","name":yAxis_title,"data":eval(data)}]}
	);
	$("#month_container").highcharts(
		{"credits":{"text":"@\u542f\u535a\u8f6f\u4ef6","enabled":false,"href":"http:\/\/www.360shop.com.cn","position":{"align":"right","y":-10}},"legend":{"enabled":true,"layout":"vertical","align":"right","verticalAlign":"middle","borderWidth":0},"xAxis":{"categories":eval(day),"title":{"text":"时间"}},"title":{"text":title + "(" + year + "年)"},"yAxis":{"title":{"text":yAxis_title},"allowDecimals":false,"plotLines":[{"value":0,"width":1,"color":"#808080"}],"min":0},"plotOptions":{"line":{"dataLabels":{"enabled":true},"enableMouseTracking":true}},"series":[{"type":"column","name":yAxis_title,"data":eval(month_data)}]}
	);
});

$('#year1').change(function(){
	$('#hidden_year1').val($(this).val());
});

$('#year2').change(function(){
	$('#hidden_year2').val($(this).val());
});

$('#month').change(function(){
	$('#hidden_month2').val($(this).val());
});

$('#stat_type1').change(function(){
	$('#hidden_stat_type1').val($(this).val());
});

$('#stat_type2').change(function(){
	$('#hidden_stat_type1').val($(this).val());
});

$('#stat_type3').change(function(){
	$('#hidden_stat_type2').val($(this).val());
});

$('#stat_type4').change(function(){
	$('#hidden_stat_type2').val($(this).val());
});
</script>
{/literal}
{/block} 

{block name="css"}
<link rel="stylesheet" href="/Public/Css/acp/AcpOrder/order_num_stat.css" type="text/css" />
{/block} 
